﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using view = RestApp.UI.Models;
using business = RestApp.BusinessLogic;

namespace RestApp.UI.App_Start
{
	public class AutoMapperConfig
	{
		public static void Configure()
		{
			Mapper.CreateMap<view.User, business.User>();
			Mapper.CreateMap<business.User, view.User>();

			Mapper.CreateMap<business.Role, view.Role>();
			Mapper.CreateMap<view.Role, business.Role>();

			Mapper.CreateMap<view.JobTitle, business.JobTitle>();
			Mapper.CreateMap<business.JobTitle, view.JobTitle>();

            Mapper.CreateMap<business.User, view.EditableUser>();
            Mapper.CreateMap<view.EditableUser, business.User>();

			Mapper.CreateMap<business.WorkGraphic, view.WorkGraphic>();
			Mapper.CreateMap<view.WorkGraphic, business.WorkGraphic>();

			Mapper.CreateMap<business.FactOfWork, view.JobFact>();
			Mapper.CreateMap<view.JobFact, business.FactOfWork>();

            Mapper.CreateMap<business.User, view.DetailedUser>()
                .ForMember(dest => dest.JobPost, src =>
                {
                    src.MapFrom(t => t.JobTitle.Name);
                })
                .ForMember(dest => dest.Role, src =>
                {
                    src.MapFrom(t => t.Role.Name);
                });
		}
	}
}